package com.example.administrator.basedemos.dagger2;

import com.example.administrator.basedemos.config.NetworkConfig;
import com.example.administrator.basedemos.utils.LogUtil;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/**
 * 创建者     ZCL
 * 创建时间   2018/3/23 16:25
 * 描述	      ${inject只能使用一个构造方法}
 * <p>
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */

public class Apiservice {
    private static final String TAG = "Dagger2";
    private final OkHttpClient client;

    //@Inject  因为需要参数所以
    public Apiservice(OkHttpClient client) {
        this.client = client;
        LogUtil.util(TAG,"inject: Apiservice");
    }


    public void register(){//因为要注册所以我们必须提供一个okhttp
        LogUtil.util(TAG,"Apiservice: regist");
             RequestBody body = RequestBody.create(NetworkConfig.JSON, "");
                     Request request = new Request.Builder()
                             .url("")
                             .post(body)
                             .build();

                     client.newCall(request).enqueue(new Callback() {
                         @Override
                         public void onFailure(Call call, IOException e) {

                         }

                         @Override
                         public void onResponse(Call call, Response response) throws IOException {

                         }
                     });

    }
}
